ARG DOCKER_ROS_DISTRO=melodic
FROM ros:probot_anno

# 配置nginx反向代理，用于浏览器下载3d模型文件
COPY probot_anno.nginx.conf /etc/nginx/sites-available/default

# 初始化 workspace.
ENV CATKIN_DIR=/catkin_ws
RUN . /opt/ros/$ROS_DISTRO/setup.sh \
 && mkdir -p $CATKIN_DIR/src \
 && cd $CATKIN_DIR/src \
 && catkin_init_workspace
WORKDIR $CATKIN_DIR


# 编译.
COPY probot_anno $CATKIN_DIR/src/probot_anno
RUN . /opt/ros/$ROS_DISTRO/setup.sh \
 && catkin_make

# 生成可执行的shell文件
RUN echo "#!/bin/bash\n\
set -e\n\
source \"${CATKIN_DIR}/devel/setup.bash\"\n\
/etc/init.d/nginx start   \n\
roslaunch probot_anno_moveit_config demo.launch \n\
exec \"\$@\"   " > /startup.sh \
 && chmod a+x /startup.sh \
 && echo "source ${CATKIN_DIR}/devel/setup.bash" >> /root/.bashrc

# 入口配置
ENTRYPOINT ["/startup.sh"]
CMD ["bash"]
